package component.model;

import java.util.List;
import javax.swing.table.DefaultTableModel;
import model.Kriteria;

/**
 *
 * @author Marlon
 */

public class KriteriaTableModel extends DefaultTableModel{
    private List<Kriteria> listKriteria;
    private int listSize;

    public KriteriaTableModel(List<Kriteria> list){
        listKriteria = list;
        listSize = list.size();
    }

    @Override
    public int getColumnCount() {
        return 3;
    } 

    @Override
    public int getRowCount() {
        return listSize;
    }
    
    @Override
    public String getColumnName(int column) {
        switch(column) {
            case 0: return "Nama Kriteria";
            case 1: return "Bobot";
            case 2: return "Nilai";
            default: return "";
        }
    }
    
    @Override
    public Object getValueAt(int row, int column) {
        Kriteria kriteria = getKriteria(row);
        switch(column) {
            case 0: return kriteria.getKriteria();
            case 1: return kriteria.getBobot();
            case 2: return kriteria.getNilai();
            default: return "";
        }
    }
    
    public Kriteria getKriteria(int row) {
        return listKriteria.get(row);
    }
}
